<!--
 * @Author: your name
 * @Date: 2019-04-22 19:43:50
 * @LastEditTime: 2022-07-28 17:48:05
 * @LastEditors: 郑祥
 * @Description: In User Settings Edit
 * @FilePath: \sybjgl_web\public\index.html
 -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />
    <meta name="theme-color" content="#000000" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>鹏成车邦</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
    <!-- 单点登陆 -->
<!--  <script>
    function getQuery() {
      if (!location.search) {
        return {};
      } else {
        var arr = [], obj = {};
        arr = location.search.slice(1).split('&');
        for (var i = 0; i < arr.length; i++) {
          obj[arr[i].split('=')[0]] = decodeURIComponent(arr[i].split('=')[1]);
        }
        return obj;
      }
    }
    // var baseURL = 'http://182.106.191.39:9002'//单点登陆服务地址
    // var baseURL = 'http://172.77.13.219:9002'//上虞地址
    // baseURL = 'http://182.106.191.39:9002/api';
    let host = window.location.host; //主机
    let reg = /^localhost+/;
    if (reg.test(host)) {
      //若本地项目调试使用
      baseURL = 'http://182.106.191.39:9002/api';
    } else {
      //动态请求地址
      baseURL = window.location.origin + '/api';
    }
    function load() {
      var UrlKeY = getQuery()
      var origin = window.location.origin
      let username = UrlKeY.xtzh
      let yyid = UrlKeY.jgbm
      if (username && yyid) {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function () {
          if (xhr.readyState == 4) {
            if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
              var data = JSON.parse(xhr.responseText)
              // var code = JSON.parse(xhr.responseText).code
              // if (code === '1') {
                sessionStorage.setItem("isAuthenticated", true);
                sessionStorage.setItem("userInfo", JSON.stringify(data));
                window.location.replace(origin + '/Index/HomePage')
              // } else {
              //   var msg = JSON.parse(xhr.responseText).msg
              //   alert(msg)
                // window.history.back()
              // }
            } else {
              alert("Request was unsuccessful: " + xhr.status);
            }
          }
        };
        xhr.open("get", baseURL + '/loginToken?yyid=' + yyid + '&username=' + username, true);
        //测试出错的效果 比如用户名错误
        // xhr.open("get", 'http://182.106.191.39:9002/loginToken?username=' + 'xxx', true);
        xhr.send(null);
      }
    }
  </script>-->
  </body>
</html>
